package com.bwie.controller;

import com.bwie.domain.TbProduct;
import com.bwie.service.TbProductService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.ProductVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping(value = "/sailer/tbProduct")
public class TbProductController {

    @Autowired
    TbProductService tbProductService;

    /**
     * 分页获取产品列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping(value = "/getProductList")
    public R getProductList(@RequestBody PageInfoVo pageInfoVo) {
        return tbProductService.getProductList(pageInfoVo);
    }

    /**
     * 获取品牌列表
     * @return
     */
    @PostMapping(value = "/getBrandList")
    public R getBrandList() {
        return tbProductService.getBrandList();
    }

    /**
     * 添加商品到购物车
     * @return
     */
    @PostMapping(value = "/addProdToCar")
    public R addProdToCar(@RequestBody TbProduct tbProduct) {
        return tbProductService.addProdToCar(tbProduct);
    }

    /**
     * 添加订单
     * @param tbProducts
     * @return
     */
    @PostMapping(value = "/addOrder")
    public R addOrder(@RequestBody ArrayList<TbProduct> tbProducts) {
        return tbProductService.addOrder(tbProducts);
    }

}
